<template>
  <div id="app">
    <!-- <router-view></router-view> -->

    <keep-alive>
        <router-view v-if="$route.meta.keepAlive"></router-view>
      </keep-alive>
    <router-view v-if="!$route.meta.keepAlive"></router-view>
  </div>
</template>

<script>
import NJS from "./tools/nhjssdk";
import router from "./router/index";
import ui from "./tools/ui";
export default {
  name: "App"
};

window.onBackPressed = function() {
  // console.log(router.currentRoute.path);
  ui.hideLoading();
  var path = router.currentRoute.path;
  // console.log("path=" + path);

  if ("/" == path || "/login" == path) {
    NJS.app({
      action: "closePage"
    });
  } else {
    var pos = path.lastIndexOf("/");
    if (pos == 0) {
      pos = 1;
    }
    router.isBack=true;
    var backPath = path.substring(0, pos);
    // console.log("backPath=" + backPath);
    router.back({ path: backPath });
  }
};
</script>

<style>
</style>
